import request from '@/utils/request';
import { OrderPaymentType, OrderStatus } from './order';

export const OrderPaymentTypeInfo = {
  [OrderPaymentType.cash]: '现结',
  [OrderPaymentType.monthly]: '月结',
  [OrderPaymentType.delivery]: '提付'
} as const;

export enum PricingType {
  number = 'number',
  area = 'area'
}

export const PricingTypeInfo = {
  [PricingType.number]: '按件数',
  [PricingType.area]: '按方数'
};

type NumberValue = string | number | null;

export interface PlaceOrder {
  customId?: number | string;
  customName: string;
  number: NumberValue;
  area: NumberValue;
  univalence: NumberValue;
  totalPrice: NumberValue;
  paymentMethod: OrderPaymentType;
  remark: string | null;
  photourl: string | null;
  pricingType: PricingType;
  width: NumberValue;
  high: NumberValue;
  length: NumberValue;
  status: OrderStatus;
}

export interface TransferPlaceOrder extends PlaceOrder {
  zcmxId: string;
  zcbz: '0' | '1';
}

export interface ReturnPlaceOrder extends PlaceOrder {
  hdmxId: string;
  fpbz: '0' | '1';
}

export interface PlaceOrderArea {
  area: NumberValue;
  width: NumberValue;
  high: NumberValue;
  length: NumberValue;
}

export const placeOrder = (data: PlaceOrder[]) => request.post('/wuliu/wares', data);
